package com.bykj.property.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import ${package.Controller}.vo.request.${entity}PageRequest;
import ${package.Entity}.${entity};
<#if table.name?contains("_n_") || table.name?contains("_m_")>
    import ${package.Entity}.${entity};
    import org.apache.ibatis.annotations.*;
    import java.util.List;
</#if >

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

/**
* <p>
    * ${table.comment!} Mapper 接口
    * </p>
*
* @author liangyiming
* @since ${date}
*/
public interface ${entity}Mapper extends BaseMapper<${entity}> {

<#if !table.name?contains("_n_") && !table.name?contains("_m_")>
    @Select("select  * from ${table.name} ")
<#assign i = 0>
<#list table.fields as field>
    <#if field.keyFlag!=true && field.name?contains("_id")>
            <#if i!=0>
                ,@Result(property = "${field.propertyName?replace("Id","")}",column = "${field.name}",one = @One(select = "${package.Mapper}.${field.capitalName?replace("Id","")}Mapper.selectById"))
            <#else>
                @Results({ @Result(property = "${field.propertyName?replace("Id","")}",column = "${field.name}",one = @One(select = "${package.Mapper}.${field.capitalName?replace("Id","")}Mapper.selectById"))
            </#if>
        <#assign i++>
    </#if>
</#list>
<#if i!=0>
    })
</#if>
    Page<${entity}> queryPage(${entity}PageRequest pageRequest);

<#else>

        @Select("select  * from ${table.fields[1].name?replace("_id","")}")
        @Results({
        @Result(property = "${table.fields[1].propertyName?replace("Id","")}",column = "${table.fields[1].name}",many = @Many(select = "${package.Mapper}.${table.fields[2].capitalName?replace("Id","")}Mapper.selectById"))
        }
        )
        Page<${entity}> queryPage(${entity}PageRequest pageRequest);
        @Select("select  * from ${table.fields[1].name?replace("_id","")}")
        @Results({
        @Result(property = "${table.fields[1].propertyName?replace("Id","")}",column = "${table.fields[1].name}",many = @Many(select = "${package.Mapper}.${table.fields[2].capitalName?replace("Id","")}Mapper.selectById"))
        }
        )
        List<${entity}> queryList(${entity} model);

</#if>
}